home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1843 / 1843.xpi / content / firebug / changeeditor.xul < prev    next >
Extensible Markup Language  |  2010-01-15  |  5KB  |  121 lines

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet href="chrome://global/skin/"?>
  3. <?xml-stylesheet href="chrome://mozapps/content/preferences/preferences.css" type="text/css"?>
  4. <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
  5. <!DOCTYPE window SYSTEM "chrome://firebug/locale/editors.dtd">
  6. <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  7.         buttons="accept,cancel"
  8.         id="firebug-external-editors-change"
  9.         width="400" height="200"
  10.         title="editors.Editor_Configuration"
  11.         onload="onLoad();"
  12.         ondialogaccept="return onAccept();"
  13.         persist="screenX screenY">
  14.   <script type="application/x-javascript" src="chrome://firebug/content/xpcom.js"/>
  15.   <script><![CDATA[
  16.       var item;
  17.       var FBL;
  18.       var internalFilefieldTextbox;
  19.       var browseButton;
  20.       function onLoad()
  21.       {
  22.          var args = window.arguments[0];
  23.          item = args.item;
  24.          FBL = args.FBL;
  25.          browseButton = document.getElementById("browse-button");
  26.          document.getElementById("name").value = item.label;
  27.          if ( item.executable )
  28.          {
  29.             try {
  30.                 var file = fbXPCOMUtils.CCIN("@mozilla.org/file/local;1", "nsILocalFile");
  31.                 file.initWithPath(item.executable);
  32.                 document.getElementById("executable").file = file;
  33.             }
  34.             catch(exc) {}
  35.          }
  36.          if ( item.cmdline )
  37.             document.getElementById("cmdline").value = item.cmdline;
  38.          onChange();
  39.          
  40.          // Localization
  41.          var element = document.getElementById("firebug-external-editors-change");
  42.          var xulString = element.getAttribute("title");
  43.          document.title = FBL.$STR(xulString);
  44.          
  45.          if (document.getAnonymousElementByAttribute && !document.getElementById("executable").file) {
  46.            setTimeout(function() {
  47.              internalFilefieldTextbox = document.getAnonymousElementByAttribute(document.getElementById("executable"), "class", "fileFieldLabel");
  48.              if (internalFilefieldTextbox) {
  49.                internalFilefieldTextbox.readOnly = false;
  50.                internalFilefieldTextbox.addEventListener("input", function(e) {
  51.                  browseButton.disabled = true;
  52.                  onChange();
  53.                }, false);
  54.              }
  55.            }, 100);
  56.          }
  57.       }
  58.       function onAccept()
  59.       {
  60.           item.label = document.getElementById("name").value;
  61.           if (!browseButton.disabled) {
  62.             var file = document.getElementById("executable").file;
  63.             item.executable = "";
  64.             if (file)
  65.                 item.executable = file.path;
  66.           } else {
  67.             item.executable = internalFilefieldTextbox.value.replace(/^\s+|\s+$/g, '');
  68.           }
  69.           item.cmdline = document.getElementById("cmdline").value;
  70.           window.arguments[1].saveChanges = true;
  71.       }
  72.       function onChange()
  73.       {
  74.           document.documentElement.getButton("accept").disabled = !(
  75.               document.getElementById("name").value && (
  76.                 (browseButton.disabled && internalFilefieldTextbox && internalFilefieldTextbox.value && internalFilefieldTextbox.value.replace(/^\s+|\s+$/g, '')) ||
  77.                 (!browseButton.disabled && document.getElementById("executable").file)
  78.               )
  79.           );
  80.       }
  81.       function onBrowse()
  82.       {
  83.         const Ci = Components.interfaces;
  84.         const nsIFilePicker = Ci.nsIFilePicker;
  85.         var picker = fbXPCOMUtils.CCIN("@mozilla.org/filepicker;1", "nsIFilePicker");
  86.         picker.init(window, "", nsIFilePicker.modeOpen);
  87.         picker.appendFilters(nsIFilePicker.filterApps);
  88.         if ( picker.show() == nsIFilePicker.returnOK && picker.file )
  89.         {
  90.           var execField = document.getElementById("executable");
  91.           execField.file = picker.file;
  92.           
  93.           if (internalFilefieldTextbox) {
  94.             internalFilefieldTextbox.readOnly = true;
  95.           }
  96.           
  97.           onChange();
  98.           return true;
  99.         }
  100.         return false;
  101.       }
  102.   ]]></script>
  103.   <vbox flex="1">
  104.       <hbox>
  105.          <label control="name" align="baseline">&changeEditor.Name;</label>
  106.          <textbox id="name" flex="1" oninput="onChange()"/>
  107.       </hbox>
  108.       <separator class="groove"/>
  109.       <hbox>
  110.          <label control="executable" align="baseline">&changeEditor.Executable;</label>
  111.          <filefield id="executable" flex="1"/>
  112.          <button id="browse-button" oncommand="onBrowse();" label="&browse.label;"/>
  113.       </hbox>
  114.       <separator class="thin"/>
  115.       <hbox align="center">
  116.           <label control="cmdline">&changeEditor.CmdLine;</label>
  117.           <textbox id="cmdline" flex="1" oninput="onChange()"/>
  118.       </hbox>
  119.   </vbox>
  120. </dialog>
  121.